package Terminal.TechnicalServices.JDom;

import EntityCondivise.ECalcoloStrategy;
import Ice.Current;
import InterfacceCondivise.XMLFacadePrxHelper;
import Terminal.TechnicalServices.Mapper.Mapper;
import Terminal.TechnicalServices.Mapper.MapperFactory;

public class XMLFacadeI extends InterfacceCondivise.XMLFacade {

	private static final long serialVersionUID = 1L;
		
	private InterfacceCondivise.XMLFacadePrxHelper xml;
	private Terminal.TechnicalServices.TSIce iceComunicator;
	private Ice.Communicator ice;
	
	/**
	 * Costruttore della classe
	 * imposta la connessione tra lo stub e il servant tramite ICE
	 */
	public XMLFacadeI()
	{
		
		iceComunicator = Terminal.TechnicalServices.TSIce.istanza();
		ice = iceComunicator.getIce();
		
		try 
		{
			Ice.ObjectPrx base = ice.stringToProxy("SimpleXMLFacadeI:" + iceComunicator.getParametriConnessione());
	        xml = (XMLFacadePrxHelper) InterfacceCondivise.XMLFacadePrxHelper.checkedCast(base);
	        
	    	if (xml == null)
	    		throw new Error("Invalid proxy");       
	        
		}
		catch (Ice.LocalException e) 
        {
            e.printStackTrace();
            iceComunicator.setStatus(1);
        } 
		catch (Exception e) 
		{
            System.err.println(e.getMessage());
            iceComunicator.setStatus(1);
        }		
		
	}
	
	
	@Override
	public ECalcoloStrategy getCalcoloStrategy(Current __current) {

		return xml.getCalcoloStrategy(); 
	}

}
